﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PersistanceLayer;

namespace BusinessLayer
{
    public class ChatBoxUser
    {
        public int Id { get; private set; }
        public string Name { get; private set; }
        public string IconUrl { get; private set; }
        public bool IsOnline { get; private set; }
        public string NickName { get; private set; }

        public Position Position { get; private set; }
        public DateTime LastSeen { get; set; }


        internal ChatBoxUser(IChatBoxUserData data)
        {
            if (data == null) return;
            //als er een entityframework gebruikt wordt, geen id instellen!
            if(data.Id != null | data.Id >0) Id = data.Id;
           
            Name = data.Name;

            IconUrl = data.IconUrl;
            IsOnline = data.IsOnline;
            NickName = data.NickName;
            Position = new Position(data.PositionLatitude, data.PositionLongitude);
            NickName = data.NickName;
            Position = new Position(data.PositionLatitude, data.PositionLongitude);
            IsOnline = data.IsOnline;

            LastSeen = data.LastSeen;
        }

        //internal ChatBoxUser(string name,string nickName,string iconUrl,Position position)
        //{
        //    lock (_myLockObject)
        //    {
        //        Id = _idCounter++;
        //    }

        //    Name = name;
        //    NickName = nickName;

        //    Random r = new Random();
        //    int i = r.Next(1, 10);

        //    IconUrl = iconUrl;
        //    string dir = "characters/";
        //    string icon = (iconUrl != "") ? iconUrl : "char"+i + ".png";
        //    IconUrl = dir+icon;

        //    IsOnline = true;
        //    LastSeen = DateTime.Now;
        //    Position = position;
        //}

        //internal ChatBoxUser(string name, string nickName, string iconUrl)
        //{
        //    lock (_myLockObject)
        //    {
        //        Id = _idCounter++;
        //    }

        //    Name = name;
        //    NickName = nickName;

        //    Random r = new Random();
        //    int i = r.Next(1, 10);

        //    IconUrl = iconUrl;
        //    string dir = "characters/";
        //    string icon = (iconUrl != "") ? iconUrl : "char" + i + ".png";
        //    IconUrl = dir + icon;

        //    IsOnline = true;
        //    LastSeen = DateTime.Now;
        //}

    }
}
